﻿using System.Collections.Generic;
using System.Web;
using System.Web.Optimization;

namespace ShieldNet
{
    public class BundleConfig
    {
        // For more information on bundling, visit http://go.microsoft.com/fwlink/?LinkId=301862
        public static void RegisterBundles(BundleCollection bundles)
        {
            //bundles.Add(new ScriptBundle("~/bundles/jquery").Include(
            //            "~/Scripts/jquery-{version}.js"));

            bundles.Add(new ScriptBundle("~/Scripts/header").Include(
                        "~/scripts/jquery-2.1.4.min.js",
                        "~/scripts/flipclock.js",
                        "~/scripts/queue.js").ForceOrdered());

            bundles.Add(new ScriptBundle("~/Scripts/footer").Include(
                        "~/scripts/wow.min.js",
                        "~/scripts/theme.js",
                        "~/scripts/bootstrap-table.js").ForceOrdered());

            //bundles.Add(new ScriptBundle("~/bundles/jqueryval").Include(
            //            "~/Scripts/jquery.validate*"));

            // Use the development version of Modernizr to develop with and learn from. Then, when you're
            // ready for production, use the build tool at http://modernizr.com to pick only the tests you need.
            //bundles.Add(new ScriptBundle("~/bundles/modernizr").Include(
            //            "~/Scripts/modernizr-*"));

            //bundles.Add(new ScriptBundle("~/bundles/bootstrap").Include(
            //          "~/Scripts/bootstrap.js",
            //          "~/Scripts/respond.js"));

            bundles.Add(new StyleBundle("~/Content/css").Include(
                      "~/content/bootstrap.min.css",
                      "~/content/animate.min.css",
                      "~/content/font-awesome.min.css",
                      "~/content/reset.css",
                      "~/content/style.css",
                      "~/content/mobile.css",
                      "~/content/bootstrap-table.css",
                      "~/content/flipclock.css").ForceOrdered());
        }
    }

    #region Các class hỗ trợ render các file trong một bundle theo thứ tự include
    internal class NonOrderingBundleOrderer : IBundleOrderer
    {
        public IEnumerable<BundleFile> OrderFiles(BundleContext context, IEnumerable<BundleFile> files)
        {
            return files;
        }
    }

    internal static class BundleExtensions
    {
        public static Bundle ForceOrdered(this Bundle bundle)
        {
            bundle.Orderer = new NonOrderingBundleOrderer();

            return bundle;
        }
    }
    #endregion
}
